package net.novasharper.icarus.rpgengine;

import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.OpenGLException;

import net.novasharper.icarus.graphics.RenderEngine;

public abstract class Game {
	private static RenderEngine renderEngine;
	private static Game gameInstance;
	protected Thread gameThread;
	
	public static RenderEngine getRenderEngine() {
		if(!Display.isCreated())
			throw new OpenGLException("Display Not Open!");
		if(null == renderEngine) {
			renderEngine = new RenderEngine();
		}
		return renderEngine;
	}
	
	public static Game getGame() {
		if(null == gameInstance)
			throw new GameInstanceException("The game has not been created yet!");
		return gameInstance;
	}
	
	public static void create(Class<? extends Game> game) throws InstantiationException, IllegalAccessException {
		if(null == gameInstance)
			gameInstance = game.newInstance();
		else
			throw new GameInstanceException("The game has already been created!");
	}
	
	protected Game() { }
	
	public abstract void enter(Map map);
}
